<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" template="/template/template.xhtml"
	xmlns:s="http://sduept.security.el/func">
	<ui:define name="head">
		<link rel="stylesheet" href="/resources/plugins/datatables/dataTables.bootstrap.css" />
		<style>
#accountInfo .box-header {
padding: 19px;
}

#statistics .box-title {
font-size: 16px;
}

#vol p:nth-child(2) {
font-size: 15px;
}

select {
color: black;
}

.ui-autocomplete-input {
width: 100%;
}
</style>
	</ui:define>
	<ui:define name="content">
		<div class='full-center-content-scroll-noheader'>
			<!-- 信息提示框 -->
			<h:form id="msgInfoDlgForm">
				<p:dialog widgetVar="msgInfoDlg" id="proEditDlg" header="提示" modal="true" height="100"
					width="500">
					<div style="text-align: center;">
						保护设备所对应的类型、保护型号可直接在列表中修改。点击列表中的设备名称，可进行保护的深入修正！点击未关联一次设备保护中的行，可进行一次设备的关联！</div>
				</p:dialog>
			</h:form>
			<h:form id="incorrectProForm">
				<p:growl id="msg" showDetail="true" />
				<p:remoteCommand name="initProInfo" update="incorrectProForm:tv"
					actionListener="#{protectCheckQueryController.init}" />
				<div style="margin-top: 4px">
					<p:toolbar>
						<f:facet name="right">
							<p:commandButton value="帮助" icon="ui-icon-help" oncomplete="PF('msgInfoDlg').show()" />
						</f:facet>
						<f:facet name="left">
							<p:selectCheckboxMenu filter="true"
								rendered="#{s:hasPermission(session,'jcsj_bhsbtz_sbwh_dc')}"
								value="#{protectCheckQueryController.selectedTypes}" filterMatchMode="startsWith"
								label="选择本次导出数据" panelStyle="width:300px">
								<f:selectItem itemLabel="线路" itemValue="line" />
								<f:selectItem itemLabel="母线" itemValue="bus" />
								<f:selectItem itemLabel="变压器" itemValue="power" />
								<f:selectItem itemLabel="断路器" itemValue="breaker" />
							</p:selectCheckboxMenu>
							<p:commandButton style="margin-left:8px" value="导出" update="msg" ajax="false"
								actionListener="#{protectCheckQueryController.exportExcelZip()}" icon="ui-icon-document"
								rendered="#{s:hasPermission(session,'jcsj_sjwh_ecsbwh_bhsbxy_bhsbjx_dc')}">
								<p:fileDownload value="#{protectCheckQueryController.protectFile}" />
							</p:commandButton>
							<p:commandButton value="刷新" update="tv"
								actionListener="#{protectCheckQueryController.refresh()}" icon="ui-icon-refresh" />
						</f:facet>
					</p:toolbar>
					<div style="float: left; width: 20%;">
						<p:menu style="width:100%;">
							<p:submenu label="已关联一次信息保护">
								<p:menuitem value="线路保护校验"
									actionListener="#{protectCheckQueryController.generateIncorrectProInfos('line')}"
									update="tv" icon="fa fa-random" />
								<p:menuitem value="母线保护校验"
									actionListener="#{protectCheckQueryController.generateIncorrectProInfos('bus')}"
									update="tv" icon="fa fa-sliders" />
								<p:menuitem value="变压器保护校验"
									actionListener="#{protectCheckQueryController.generateIncorrectProInfos('power')}"
									update="tv" icon="fa fa-bolt" />
								<p:menuitem value="断路器保护校验"
									actionListener="#{protectCheckQueryController.generateIncorrectProInfos('breaker')}"
									update="tv" icon="fa fa-exclamation-triangle" />
							</p:submenu>
							<p:submenu label="未关联一次信息保护">
								<p:menuitem value="未关联厂站保护"
									actionListener="#{protectCheckQueryController.generateIncorrectProInfos('unbindSt')}"
									update="tv" icon="fa fa-chain-broken" />
								<p:menuitem value="未关联一次设备保护"
									actionListener="#{protectCheckQueryController.generateIncorrectProInfos('unbindEqu')}"
									update="tv" icon="fa fa-window-close-o" />
							</p:submenu>
						</p:menu>
					</div>
					<div style="float: right; width: 80%;">
						<p:tabView style="border:none" id="tv" dynamic="true"
							value="#{protectCheckQueryController.tabTiltes}" var="item">
							<p:ajax event="tabChange" process="@this"
								listener="#{protectCheckQueryController.onTabChange}" />
							<p:tab title="#{item}">
								<p:dataTable id="incorrectProTable" style="text-align:center" var="incorrectPro"
									rowKey="#{incorrectPro.id}" paginator="true" rows="20" editable="true" editMode="cell"
									paginatorTemplate="{Customization} {FirstPageLink} {PreviousPageLink} 
									{PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
									rowsPerPageTemplate="20,50,100" paginatorPosition="bottom"
									value="#{protectCheckQueryController.incorrectPro}" selection="#{protectCheckQueryController.selected}" 
									emptyMessage="无记录" sortBy="#{incorrectPro.comment}">
									<p:ajax event="cellEdit" update="incorrectProTable"
										listener="#{protectCheckQueryController.onCellEdit}" />
									<p:ajax event="rowSelect" update="incorrectProTable editForm:editDlg currentViewName"
										oncomplete="showEditDlg()" />
										<f:facet name="{Customization}">
											<p:outputLabel value="总计：#{protectCheckQueryController.incorrectPro.size()} 条记录" style="margin-right:20px;" />
										</f:facet>
									<!-- 线路用此列 -->
									<p:column headerText="设备名称"
										rendered="#{protectCheckQueryController.currentView.equals('line')}" groupRow="true">
										<p:commandLink value="#{incorrectPro.protectedName}"
											style="color:red; text-decoration:underline"
											actionListener="#{protectCheckQueryController.openLineProEditDialog(incorrectPro)}" />
									</p:column>
									<p:column headerText="变电站名称"
										rendered="#{protectCheckQueryController.currentView.equals('line')}">
										<h:outputText value="#{incorrectPro.substationName}" />
									</p:column>
									<!-- ================= -->
									<!-- 变压器，母线用此列 -->
									<p:column headerText="变电站名称"
										rendered="#{protectCheckQueryController.currentView.equals('power')
											||protectCheckQueryController.currentView.equals('breaker')||protectCheckQueryController.currentView.equals('bus')}">
										<p:commandLink value="#{incorrectPro.substationName}" update="incorrectProForm:msg"
											actionListener="#{protectCheckQueryController.openStProEditDialog(incorrectPro)}"
											style="color:red; text-decoration:underline" />
									</p:column>
									<p:column headerText="变电站名称"
										rendered="#{protectCheckQueryController.currentView.equals('unbindEqu')}">
										<h:outputText value="#{incorrectPro.substationName}" />
									</p:column>
									<p:column headerText="设备名称"
										rendered="#{protectCheckQueryController.currentView.equals('unbindEqu')||protectCheckQueryController.currentView.equals('power')
											||protectCheckQueryController.currentView.equals('breaker')||protectCheckQueryController.currentView.equals('bus')}">
										<h:outputText value="#{incorrectPro.protectedName}" />
									</p:column>
									<!-- 未绑定变电站 -->
									<p:column headerText="保信变电站(用于参考)"
										rendered="#{protectCheckQueryController.currentView.equals('unbindSt')}">
										<p:commandLink value="#{incorrectPro.privateStationName}"
											actionListener="#{protectCheckQueryController.openUnbindProEditDialog(incorrectPro)}"
											style="color:red; text-decoration:underline" />
									</p:column>
									<p:column headerText="变电站"
										rendered="#{protectCheckQueryController.currentView.equals('unbindSt')}">
										<h:outputText value="#{incorrectPro.substationName}" />
									</p:column>
									<p:column headerText="设备名称"
										rendered="#{protectCheckQueryController.currentView.equals('unbindSt')}">
										<h:outputText value="#{incorrectPro.protectedName}" />
									</p:column>
									<!-- ================= -->
									<p:column headerText="保护名称">
										<h:outputText value="#{incorrectPro.name}" />
									</p:column>
									<p:column headerText="类型">
										<p:cellEditor>
											<f:facet name="output">
												<p:outputLabel value="#{incorrectPro.type}" />
											</f:facet>
											<f:facet name="input">
												<p:selectOneMenu id="lazy" value="#{incorrectPro.type}" style="width:125px">
													<f:selectItem itemLabel=" " itemValue="" />
													<f:selectItems value="#{protectCheckQueryController.proKinds}" />
												</p:selectOneMenu>
											</f:facet>
										</p:cellEditor>
									</p:column>
									<p:column headerText="保护型号">
										<p:cellEditor>
											<f:facet name="output">
												<p:outputLabel value="#{incorrectPro.devType}" />
											</f:facet>
											<f:facet name="input">
												<p:inputText value="#{incorrectPro.devType}" />
											</f:facet>
										</p:cellEditor>
									</p:column>
									<p:column headerText="保护厂家">
										<h:outputText value="#{incorrectPro.devManufacturer}" />
									</p:column>
								</p:dataTable>
							</p:tab>
						</p:tabView>
					</div>
				</div>
			</h:form>
			<!-- 关联一次设备 -->
			<h:form id="editForm">
				<p:dialog widgetVar="editDlg" header="保护编辑" modal="true" id="editDlg" width="410" height="350">
					<p:toolbar>
						<f:facet name="left">
							<p:commandButton id="editSaveBtn" value="保存" icon="ui-icon-disk"
								update="incorrectProForm:msg incorrectProForm:tv" oncomplete="PF('editDlg').hide()"
								actionListener="#{protectCheckQueryController.update}" />
						</f:facet>
					</p:toolbar>
					<p:outputPanel id="editDetail" style="text-align:center;">
						<p:panelGrid columns="2">
							<h:outputText value="保护名称" />
							<p:inputText value="#{protectCheckQueryController.selected.name}" style="width:100%"
								label="protectedName"></p:inputText>
							<h:outputText value="保护类型" />
							<p:selectOneMenu value="#{protectCheckQueryController.selected.type}" style="width:100%">
								<f:selectItems value="#{protectCheckQueryController.proKinds}" var="type"
									itemLabel="#{type}" itemValue="#{type}" />
							</p:selectOneMenu>

							<h:outputText value="变电站" />
							<p:autoComplete id="selectStation_auto" scrollHeight="400" dropdown="true"
								value="#{protectCheckQueryController.selected.substationName}"
								completeMethod="#{protectCheckQueryController.completeStationNames}">
							</p:autoComplete>
							<h:outputText value="一次设备名称" />

							<p:row>
								<p:inputText readonly="true" id="deviceName"
									value="#{protectCheckQueryController.selected.protectedName}" />
								<p:commandButton value="选择"
									actionListener="#{protectCheckQueryController.getEquipmentByStation}">
									<p:ajax event="dialogReturn" update="deviceName"
										listener="#{protectCheckQueryController.onEquDialogChosenListener}" />
								</p:commandButton>
							</p:row>
							<h:outputText value="一次设备类型" />
							<p:selectOneMenu value="#{protectCheckQueryController.selected.protectedType}"
								style="width:100%">
								<!-- <p:ajax event="change"
													listener="#{protectCheckQueryController.onProtectedTypeChange}"
													update="selectEquipment"></p:ajax> -->
								<f:selectItems value="#{protectCheckQueryController.protectedTypes}" var="protectedType"
									itemLabel="#{protectedType}" itemValue="#{protectedType}" />
							</p:selectOneMenu>
							<h:outputText value="保护型号:" />
							<p:inputText value="#{protectCheckQueryController.selected.devType}" style="width:100%"
								label="protectedName"></p:inputText>
							<!-- <p:autoComplete
												value="#{protectCheckQueryController.selected.devType}"
												style="width:100%"
												completeMethod="#{protectCheckQueryController.completeDevTypes}"
												scrollHeight="400" /> -->
							<h:outputText value="生产厂家" />
							<p:autoComplete scrollHeight="400" dropdown="true"
								value="#{protectCheckQueryController.selected.devManufacturer}"
								completeMethod="#{protectCheckQueryController.completeDevManufacturer}">
							</p:autoComplete>
						</p:panelGrid>
					</p:outputPanel>
				</p:dialog>
			</h:form>
			<h:inputHidden id="currentViewName" value="#{protectCheckQueryController.currentView}" />
		</div>

	</ui:define>
	<ui:define name="contentend">
		<script src="/resources/plugins/datatables/jquery.dataTables.js"></script>
		<script src="/resources/plugins/datatables/dataTables.bootstrap.min.js"></script>
		<script src="/resources/js/tables/mytable.js"></script>
		<script src="/resources/plugins/layer/layer.js"></script>
		<script src="/resources/js/mymodal.js"></script>
		<script>
			$(function() {
				//设置充满内容的div滚动区高度
				var h = $(".full-content-scroll").height();
				$(".full-content-scroll").height(h - 45);
				$("#tabView .slimScrollDiv").height();
			})
			var menushow = false;

			//打开关联一次设备框
			function showEditDlg() {
				var currViewName = $("#currentViewName").val();
				if (currViewName == "unbindEqu") {
					PF('editDlg').show();
				}
			}

			//保护修正数据初始化
			function initProtectRevises() {
				var buttonPro = document.getElementById("initProRevisesForm:initProRevisesData");
				buttonPro.click();
			}

			function myPage() {
				MyModal.showModal("/ui/dataview/fault/transmissionEquipment.xhtml", 1200, 600);
			}
		</script>
	</ui:define>
</ui:composition>
